<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 没初始值
        let arr = [1, 2, 3, 4]
        const y = arr.reduce((a, b) => a + b)
        document.write(y)
        // 也可以用于累乘或其他
        const X = arr.reduce((a, b) => a * b)
        document.write(X)
        // 有初始值
        const z = arr.reduce((a, b) => a * b, 100)
        document.write(z)
    </script>
</body>

</html>